refactor: split the generator engine into focused modules - #20
Merged
Conversation
src/mdx-to-nextjs-generator.ts shrinks from ~2760 lines to a thin orchestrator that wires together eleven new modules under src/generator/: - secure-source-fs.ts: SecureSourceFs, a hardened fs layer that scopes reads to the documentation root and project root, guarding against path traversal and symlink escapes. - app-scaffolder.ts: AppScaffolder writes the initial Next.js app structure (appStructure/obsoleteFiles/startingDocsStructure) plus the robots, next.config, pnpm-workspace, and proxy templates. - project-config-repository.ts: ProjectConfigRepository reads, validates, and writes the JSON config files (navigation, sections, fonts, analytics) through SecureSourceFs. - section-resolver.ts: validateSectionsConfig, discoverSections, addApiReferenceSection, and determineSectionRoute resolve an MDX file's section and slug. - page-catalog.ts: parseMdxPageMeta, validateRouteCollisions, and mergePages build and merge the page-metadata catalog from MDX frontmatter. - page-renderer.ts: renderMdxPage, renderHomepage, and renderSectionPage turn parsed MDX into page content and RSS route state. - generated-route-manager.ts: GeneratedRouteManager reconciles routes owned by generated MDX pages via the GeneratedArtifacts registry. - api-reference-generator.ts: ApiReferenceGenerator produces the OpenAPI-driven synthetic reference pages and routes. - public-asset-manager.ts: PublicAssetManager mirrors the public/ directory and manages the llms.txt/llms-full.txt/skill.md/ .well-known/mcp.json aggregate files. - site-artifacts.ts: buildSitemapEntries and related helpers generate sitemap.xml, robots.txt, and the llms files from the page catalog. - watch-coordinator.ts: WatchCoordinator owns the chokidar watchers for MDX, config, font, analytics, doccupine.json, public/, and OpenAPI spec sources. No behavioral changes are intended; this is a pure extraction to keep each concern independently readable and testable.
StyledAccordionTitle already reimplements a full manual button reset (appearance, border, background, font, cursor) inline, so wrapping cherry's Button and layering resetButton on top only fought that styling with Button's own defaults. Switch the styled-component base to a plain styled.button and drop the now-unused Button/resetButton import.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/mdx-to-nextjs-generator.ts(~2760 lines) into eleven focused modules undersrc/generator/:secure-source-fs,app-scaffolder,project-config-repository,section-resolver,page-catalog,page-renderer,generated-route-manager,api-reference-generator,public-asset-manager,site-artifacts, andwatch-coordinator. The generator file itself becomes a thin orchestrator that wires these modules together.Button/resetButtonwrapper in favor of a plainstyled.button, sinceStyledAccordionTitlealready reimplements a full manual button reset inline.Test plan
pnpm build(tsc compiles clean)pnpm test(228 tests passing across 15 files)pnpm format:check(Prettier clean)